#include<iostream>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
LL a[N];
LL s[N];
int n;
int main()
{
	cin >> n;
	LL ans = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		s[i + 1] = s[i] + a[i];
		//ans += a[i];
	}
	int x, y;
	cin >> x >> y;
	LL ans1 = abs(s[y] - s[x]);
	LL ans2 = s[n + 1] - ans1;
	//cout << "ans1==" << ans1 << endl;
	//cout << "ans2==" << ans2 << endl;
	cout << abs(min(ans1, ans2)) << endl;
	return 0;
}